/*
 * @Autor: dingxiaolin
 * @Date: 2020-05-28 22:48:51
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2020-06-01 21:40:34
 */

import React from "react";
import { render } from "react-dom";
import {
  // HashRouter as Router,
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect,
} from "react-router-dom";
import { Provider } from "react-redux";

import zhCN from "antd/lib/locale-provider/zh_CN";
import { ConfigProvider } from "antd";

import App from "./App";
import store from "./store";
import { mainRoutes } from "./routes";

import "./styles/index.less";

render(
  <Provider store={store}>
    <ConfigProvider locale={zhCN} prefixCls={"ant"}>
      <Router>
        <Switch>
          {/* 常用路由 */}
          {mainRoutes.map((route) => {
            return (
              <Route
                key={route.pathname}
                path={route.pathname}
                component={route.component}
              />
            );
          })}
          {/* 权限路由 */}
          <Route path="/admin" component={App} />
          <Redirect to="/admin" from="/" exact />
          <Redirect to="/404" />
        </Switch>
      </Router>
    </ConfigProvider>
  </Provider>,
  document.querySelector("#root")
);
